package bb.lanxing.mvvm.base.viewmodel;

public class ContextAction {
    public static String ACTION_FINISH = "ACTION_FINISH";
    public static String ACTION_HIDE_LOADING = "ACTION_HIDE_LOADING";
    public static String ACTION_REFRESH = "ACTION_REFRESH";
    public static String ACTION_SHOW_LOADING = "ACTION_SHOW_LOADING";
    private String action;


    public interface ActionHandler {
        void onFinish(String str);

        void onHideLoading(String str);

        void onReFresh(String str);

        void onShowLoading(String str);
    }

    public ContextAction() {
        this.action = "";
    }

    public ContextAction(String str) {
        this.action = str;
    }

    public String getAction() {
        return this.action;
    }

    public ContextAction setAction(String str) {
        this.action = str;
        return this;
    }

    public static void handle(String str, ActionHandler actionHandler) {
        if (str.equals(ACTION_FINISH)) {
            actionHandler.onFinish(str);
        } else if (str.equals(ACTION_SHOW_LOADING)) {
            actionHandler.onShowLoading(str);
        } else if (str.equals(ACTION_HIDE_LOADING)) {
            actionHandler.onHideLoading(str);
        } else if (str.equals(ACTION_REFRESH)) {
            actionHandler.onReFresh(str);
        }
    }
}
